﻿@model PagedList.IPagedList<SoftHotel.Models.Ambiente>

@{
    ViewBag.Title = "Ambientes";
}

<h2>Ambientes</h2>  

<fieldset>
<legend>Búsqueda de Ambientes</legend>


@using (Html.BeginForm())
{
    <p>
        Buscar por nombre: @Html.TextBox("SearchString", ViewBag.CurrentFilter as string)  
        <input type="submit" value="Buscar" /></p>
}

<br />

<table rules="all" style="border-color: #bgbgbg; width: 700px; margin-bottom: 0px;" border="1">
    <tr>            
        <th style="font-weight: bold; width: 50px;" align="center">
            ID Ambiente
        </th>   
        <th style="font-weight: bold; width: 150px;" align="center">
            Nombre
        </th>
        <th style="font-weight: bold; width: 150px;" align="center">
           Tipo Ambiente </th>
        <th style="font-weight: bold; width: 150px;" align="center">
            Descripcion
        </th>
        
      
    </tr>
    @foreach (var genre in Model)
    {
              
    <tr style="color:@(genre.nombre == "carlos" ? "red" : "black")">     
            
       <td align="center"> 
       @using (Ajax.BeginForm("BuscarAmbiente", "ReservaHab",
       null
        , new AjaxOptions
        {
            UpdateTargetId = "update-message",
            InsertionMode = InsertionMode.Replace,
            HttpMethod = "POST",
            OnSuccess = "searchSuccess"
        }, new { @id = "searchForm"+@genre.idAmbiente }))
       {
    
    <div id="update-message" class="error invisible"></div>
        <input data-val="true" data-val-number="The field idAmbiente must be a number." data-val-required="El campo idAmbiente es obligatorio." id="idAmbiente" name="idAmbiente" type="hidden" value="@genre.idAmbiente" />   
        @Html.HiddenFor(model => genre.idAmbiente,new {id="idAmbiente"+@genre.idAmbiente })
           @Html.HiddenFor(model => genre.nombre, new { id = "nombre" + @genre.idAmbiente }) 
             @Html.HiddenFor(model => genre.tipoAmbiente, new { id = "tipoAmb" + @genre.idAmbiente }) 
             @Html.HiddenFor(model => genre.descripcion, new { id = "desc" + @genre.idAmbiente }) 
          
         
           <input type="submit" value="@genre.idAmbiente" />
       } 
        

        </td>
        <td align="center">
            @genre.nombre
        </td>
        <td align="center"> 
            @genre.tipoAmbiente
        </td>       
       
        <td align="center"> 
            @genre.descripcion
        </td>
    </tr>
    }     
</table>

<br />
<div>
    Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber)
    of @Model.PageCount
     
    @if (Model.HasPreviousPage)
    {
        @Html.ActionLink("<<", "Index", new { page = 1, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter })
        @Html.Raw(" ");
        @Html.ActionLink("< Anterior", "Index", new { page = Model.PageNumber - 1, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter })
    }
    else
    {
        @:<<
        @Html.Raw(" ");
        @:< Prev
    }
     
    @if (Model.HasNextPage)
    {
        @Html.ActionLink("Siguiente >", "Index", new { page = Model.PageNumber + 1, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter })
        @Html.Raw(" ");
        @Html.ActionLink(">>", "Index", new { page = Model.PageCount, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter })
    }
    else
    {
        @:Next >
        @Html.Raw(" ")
        @:>>
    }
</div>

</fieldset>
